package com.ourteam.product.model.dao.impl;

import com.ourteam.product.model.dao.IProductModelObjectDAO;
import com.ourteam.product.model.dao.ProductModelObject;
import com.ourteam.product.model.dao.ProductModelObjectDAOQueryBean;

import net.dao.AbstractSpringDAO;
import net.dao.DataAccessObjectHelper;

import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.lang.StringUtils;

import org.springframework.jdbc.core.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;


/**
 * Template Name : DAO服务对象
 * Template Version : 1
 * Template Last Modfiy Date : Fri Nov 17 11:00:11 IRKT 2017
 * Auto Generate Date : 2017-11-17 11:01:13
  * Warning ! This file will be overwrite when regenerate !
  *
 */
public class AbstractProductModelObjectDAOJdbcImpl extends AbstractSpringDAO
    implements IProductModelObjectDAO {
    public static final String[] ENTITY_FIELDS = new String[] {
            Id, PackageId, ObjectCode, ObjectName, ObjectType, IsGenerate,
            Status, Remarks, SubmitterId, CreatorName, CreateTime,
            LastModifierName, LastModifyTime, DomainId, PackageName, DomainName,
            DomainCode
        };
    public static final String[] ENTITY_PROPERTIES = new String[] {
            _DataObjectProperty.Id, _DataObjectProperty.PackageId,
            _DataObjectProperty.ObjectCode, _DataObjectProperty.ObjectName,
            _DataObjectProperty.ObjectType, _DataObjectProperty.IsGenerate,
            _DataObjectProperty.Status, _DataObjectProperty.Remarks,
            _DataObjectProperty.SubmitterId, _DataObjectProperty.CreatorName,
            _DataObjectProperty.CreateTime, _DataObjectProperty.LastModifierName,
            _DataObjectProperty.LastModifyTime, _DataObjectProperty.DomainId,
            _DataObjectProperty.PackageName, _DataObjectProperty.DomainName,
            _DataObjectProperty.DomainCode
        };
    public static final String[] ENTITY_PK_FIELDS = new String[] { Id };
    public static final String[] ENTITY_AUTO_GEN_PK_FIELDS = new String[] { Id };
    public static final String[] ENTITY_UNIQUE_FIELDS = new String[] {  };
    private static String relatedJoinSQL = null;
    private static String basicFilterSQL = null;
    private DataAccessObjectHelper<ProductModelObject, ProductModelObjectDAOQueryBean> daoHelper;
    private com.ourteam.product.model.dao.impl.AbstractProductModelPropertyDAOJdbcImpl ProductModelPropertyDao;
    private com.ourteam.product.model.dao.impl.AbstractProductModelObjectRelateDAOJdbcImpl ProductModelObjectRelateDao;

    public AbstractProductModelObjectDAOJdbcImpl() {
        super();
        daoHelper = new DataAccessObjectHelper<ProductModelObject, ProductModelObjectDAOQueryBean>(this);
    }

    protected String getEntityName() {
        return EntityName;
    }

    protected String[] getEntityFields() {
        return ENTITY_FIELDS;
    }

    protected String[] getEntityProperties() {
        return ENTITY_PROPERTIES;
    }

    protected String[] getEntityPKFields() {
        return ENTITY_PK_FIELDS;
    }

    protected String[] getEntityAutoGenPKFields() {
        return ENTITY_AUTO_GEN_PK_FIELDS;
    }

    protected String[] getEntityUniqueFields() {
        return ENTITY_UNIQUE_FIELDS;
    }

    protected String getBaiscQueryFilter() {
        if (basicFilterSQL == null) {
            StringBuffer basicFilterSQLbuffer = new StringBuffer();

            basicFilterSQL = basicFilterSQLbuffer.toString();
        }

        return basicFilterSQL;
    }

    protected String getRelatedJoinSQL() {
        if (relatedJoinSQL == null) {
            StringBuffer relatedJoinSQLBuffer = new StringBuffer();

            relatedJoinSQLBuffer.append(" LEFT JOIN ")
                                .append(com.ourteam.product.model.dao.IProductModelPackageDAO.EntityName)
                                .append(" PRODUCT_MODEL_PACKAGE ");

            relatedJoinSQLBuffer.append(" ON ( ");

            relatedJoinSQLBuffer.append(StringUtils.replace(
                    com.ourteam.product.model.dao.IProductModelPackageDAO.Id,
                    com.ourteam.product.model.dao.IProductModelPackageDAO.EntityName +
                    ".", "PRODUCT_MODEL_PACKAGE."));
            relatedJoinSQLBuffer.append(" = ").append(PackageId);

            relatedJoinSQLBuffer.append(" ) ");

            relatedJoinSQLBuffer.append(" LEFT JOIN ")
                                .append(com.ourteam.product.model.dao.IProductModelDomainDAO.EntityName)
                                .append(" PRODUCT_MODEL_DOMAIN ");

            relatedJoinSQLBuffer.append(" ON ( ");

            relatedJoinSQLBuffer.append(StringUtils.replace(
                    com.ourteam.product.model.dao.IProductModelDomainDAO.Id,
                    com.ourteam.product.model.dao.IProductModelDomainDAO.EntityName +
                    ".", "PRODUCT_MODEL_DOMAIN."));
            relatedJoinSQLBuffer.append(" = ").append(DomainId);

            relatedJoinSQLBuffer.append(" ) ");

            relatedJoinSQL = relatedJoinSQLBuffer.toString();
        }

        return relatedJoinSQL;
    }

    /**
         * Check Data Unique
         * @param aProductModelObject
         * @throws Exception
         */
    public boolean checkIsUnique(ProductModelObject aProductModelObject)
        throws Exception {
        if (aProductModelObject == null) {
            return true;
        }

        List valueList = new ArrayList();

        List pkValueList = new ArrayList();

        pkValueList.add(aProductModelObject.getId());

        return isUnique(valueList.toArray(new Object[valueList.size()]),
            pkValueList.toArray(new Object[pkValueList.size()]));
    }

    /**
     * Insert Data
     * @param aProductModelObject
     * @throws Exception
     */
    public void insert(ProductModelObject aProductModelObject)
        throws Exception {
        super.doInsert(aProductModelObject);
    }

    /**
         * Batch Insert Datas
         * @param aProductModelObject
         * @throws Exception
         */
    public void batchInsert(ProductModelObject[] aProductModelObjects)
        throws Exception {
        super.doBatchInsert(aProductModelObjects);
    }

    /**
         * Delete Data
         * @param  final long id         *
         * @throws Exception
         */
    public void delete(final long id) throws Exception {
        super.doDeleteById(new Object[] { new Long(id) });
    }

    /**
     * Delete Datas
     * @param queryBean
     * @throws Exception
     */
    public void delete(ProductModelObjectDAOQueryBean queryBean)
        throws Exception {
        super.doDeleteByQuery(queryBean);
    }

    public void delete(ProductModelObject aProductModelObject)
        throws Exception {
        delete(aProductModelObject.getId());
    }

    /**
     * Update Data Selective
     * @param aProductModelObject
     * @throws Exception
     */
    public void update(ProductModelObject aProductModelObject)
        throws Exception {
        if (aProductModelObject.getId() == 0) {
            throw new Exception(
                "Can not update object data whith out primary key value");
        }

        super.doUpdate(aProductModelObject);

        ProductModelObject tempObj = findById(aProductModelObject.getId());

        if (tempObj != null) {
            PropertyUtils.copyProperties(aProductModelObject, tempObj);
        }
    }

    /**
     * Batch Update Datas
     * @param aProductModelObjects[]
     * @throws Exception
     */
    public void batchUpdate(ProductModelObject[] aProductModelObjects)
        throws Exception {
        super.doBatchUpdate(aProductModelObjects);
    }

    /**
         * Update Data By Condictions
         * @param aProductModelObject
         * @param aValueCriteria
         * @param aTransaction
         * @throws Exception
         */
    public void update(ProductModelObject aProductModelObject,
        ProductModelObjectDAOQueryBean aQueryBean) throws Exception {
        super.doUpdateByQuery(aProductModelObject, aQueryBean);
    }

    /**
     * Update Data By Condictions
     * @param aQueryBean
     * @throws Exception
     */
    public void update(ProductModelObjectDAOQueryBean aQueryBean)
        throws Exception {
        super.doUpdateByQuery(aQueryBean);
    }

    protected void checkNullValue(ProductModelObject aProductModelObject)
        throws Exception {
        if (aProductModelObject.getObjectCode() == null) {
            throw new Exception(
                "The ProductModelObject.objectCode value is not allow NULL");
        }

        if (aProductModelObject.getObjectName() == null) {
            throw new Exception(
                "The ProductModelObject.objectName value is not allow NULL");
        }

        if (aProductModelObject.getObjectType() == null) {
            throw new Exception(
                "The ProductModelObject.objectType value is not allow NULL");
        }

        if (aProductModelObject.getIsGenerate() == null) {
            throw new Exception(
                "The ProductModelObject.isGenerate value is not allow NULL");
        }

        if (aProductModelObject.getStatus() == null) {
            throw new Exception(
                "The ProductModelObject.status value is not allow NULL");
        }

        if (aProductModelObject.getRemarks() == null) {
            throw new Exception(
                "The ProductModelObject.remarks value is not allow NULL");
        }

        if (aProductModelObject.getPackageName() == null) {
            throw new Exception(
                "The ProductModelObject.packageName value is not allow NULL");
        }

        if (aProductModelObject.getDomainCode() == null) {
            throw new Exception(
                "The ProductModelObject.domainCode value is not allow NULL");
        }

        if (aProductModelObject.getDomainName() == null) {
            throw new Exception(
                "The ProductModelObject.domainName value is not allow NULL");
        }
    }

    /**
     * Get Data By ID
     * @param  final long id         * @return  ${businessObject.name}
     * @throws Exception
     */
    public ProductModelObject findById(final long id) throws Exception {
        ProductModelObjectDAOQueryBean queryBean = new ProductModelObjectDAOQueryBean();

        ProductModelObjectDAOQueryBean.Criteria criteria = queryBean.createCriteria();

        criteria.andIdEqualTo(id);

        //queryBean.setDistinct(true);
        ProductModelObject[] ProductModelObjects = query(queryBean);

        if (ProductModelObjects.length == 0) {
            return null;
        } else {
            return ProductModelObjects[0];
        }
    }

    /**
         * Query Data
         * @param queryBean
         * @return ProductModelObject[]
         * @throws Exception
         */
    public ProductModelObject[] query(ProductModelObjectDAOQueryBean queryBean)
        throws Exception {
        List result = super.doQuery(queryBean,
                new JdbcProductModelObjectRowMapper());

        return (ProductModelObject[]) result.toArray(new ProductModelObject[result.size()]);
    }

    /**
     * Query ${businessObject.name} Selective
     * @param queryBean
     * @return Map[]
     * @model
     * @throws Exception
     */
    public Map<String, Object>[] querySelective(
        ProductModelObjectDAOQueryBean queryBean) throws Exception {
        if (queryBean.getSelectProperties().isEmpty()) {
            queryBean.addAllSelectProperties();
        }

        return super.doQuerySelective(queryBean);
    }

    /**
     * Query Data Count
     * @param queryBean
     * @return int
     * @throws Exception
     */
    public int queryCount(ProductModelObjectDAOQueryBean queryBean)
        throws Exception {
        return super.doQueryCount(queryBean);
    }

    public void synchronize(ProductModelObject[] aProductModelObjects,
        ProductModelObjectDAOQueryBean queryBean) throws Exception {
        daoHelper.synchronize(aProductModelObjects, queryBean);
    }

    public void synchronize(ProductModelObject[] aProductModelObjects,
        ProductModelObjectDAOQueryBean queryBean,
        net.dao.IDataAccessInterface.ISynchronizeCallback<ProductModelObject> callBack)
        throws Exception {
        daoHelper.synchronize(aProductModelObjects, queryBean, callBack);
    }

    public void setProductModelPropertyDao(
        com.ourteam.product.model.dao.IProductModelPropertyDAO ProductModelPropertyDao) {
        this.ProductModelPropertyDao = (com.ourteam.product.model.dao.impl.AbstractProductModelPropertyDAOJdbcImpl) ProductModelPropertyDao;
    }

    /**
     * Query Related ProductModelProperty
    * @param queryBean
     * @throws Exception
     */
    public com.ourteam.product.model.dao.ProductModelProperty[] queryProductModelProperty(
        ProductModelObjectDAOQueryBean queryBean) throws Exception {
        StringBuffer joinSQL = new StringBuffer();

        joinSQL.append(" LEFT JOIN ").append(EntityName).append(" ON ( ");

        joinSQL.append(com.ourteam.product.model.dao.IProductModelPropertyDAO.ObjectId)
               .append(" = ").append(Id);

        joinSQL.append(" ) ");

        String entityName = com.ourteam.product.model.dao.impl.ProductModelPropertyDAO.EntityName +
            " ref_ProductModelProperty";

        String[] entityFields = com.ourteam.product.model.dao.impl.ProductModelPropertyDAO.ENTITY_FIELDS;

        String[] entityProperties = com.ourteam.product.model.dao.impl.ProductModelPropertyDAO.ENTITY_PROPERTIES;

        List list = ProductModelPropertyDao.doQuery(entityName, entityFields,
                entityProperties, queryBean, joinSQL.toString(),
                new com.ourteam.product.model.dao.impl.ProductModelPropertyDAO.JdbcProductModelPropertyRowMapper());

        return (com.ourteam.product.model.dao.ProductModelProperty[]) list.toArray(new com.ourteam.product.model.dao.ProductModelProperty[list.size()]);
    }

    /**
     * Query Related ProductModelProperty Selective
     * @param queryBean
     * @return Map[]
     * @model
     * @throws Exception
     */
    public Map<String, Object>[] queryProductModelPropertySelective(
        ProductModelObjectDAOQueryBean queryBean) throws Exception {
        if (queryBean.getSelectProperties().isEmpty()) {
            queryBean.addSelectProperty(com.ourteam.product.model.dao.IProductModelPropertyDAO.Id,
                "id");

            queryBean.addSelectProperty(com.ourteam.product.model.dao.IProductModelPropertyDAO.ObjectId,
                "objectId");

            queryBean.addSelectProperty(com.ourteam.product.model.dao.IProductModelPropertyDAO.PropertyCode,
                "propertyCode");

            queryBean.addSelectProperty(com.ourteam.product.model.dao.IProductModelPropertyDAO.PropertyName,
                "propertyName");

            queryBean.addSelectProperty(com.ourteam.product.model.dao.IProductModelPropertyDAO.DataTypeId,
                "dataTypeId");

            queryBean.addSelectProperty(com.ourteam.product.model.dao.IProductModelPropertyDAO.DataLength,
                "dataLength");

            queryBean.addSelectProperty(com.ourteam.product.model.dao.IProductModelPropertyDAO.DataAccuracy,
                "dataAccuracy");

            queryBean.addSelectProperty(com.ourteam.product.model.dao.IProductModelPropertyDAO.IsArray,
                "isArray");

            queryBean.addSelectProperty(com.ourteam.product.model.dao.IProductModelPropertyDAO.IsAllowNull,
                "isAllowNull");

            queryBean.addSelectProperty(com.ourteam.product.model.dao.IProductModelPropertyDAO.IsPrimaryKey,
                "isPrimaryKey");

            queryBean.addSelectProperty(com.ourteam.product.model.dao.IProductModelPropertyDAO.IsAutoInc,
                "isAutoInc");

            queryBean.addSelectProperty(com.ourteam.product.model.dao.IProductModelPropertyDAO.SortIndex,
                "sortIndex");

            queryBean.addSelectProperty(com.ourteam.product.model.dao.IProductModelPropertyDAO.Status,
                "status");

            queryBean.addSelectProperty(com.ourteam.product.model.dao.IProductModelPropertyDAO.Remarks,
                "remarks");

            queryBean.addSelectProperty(com.ourteam.product.model.dao.IProductModelPropertyDAO.DataType,
                "dataType");

            queryBean.addSelectProperty(com.ourteam.product.model.dao.IProductModelPropertyDAO.DefaultValue,
                "defaultValue");

            queryBean.addSelectProperty(com.ourteam.product.model.dao.IProductModelPropertyDAO.IsUnique,
                "isUnique");

            queryBean.addSelectProperty(com.ourteam.product.model.dao.IProductModelPropertyDAO.SubmitterId,
                "submitterId");

            queryBean.addSelectProperty(com.ourteam.product.model.dao.IProductModelPropertyDAO.CreatorName,
                "creatorName");

            queryBean.addSelectProperty(com.ourteam.product.model.dao.IProductModelPropertyDAO.CreateTime,
                "createTime");

            queryBean.addSelectProperty(com.ourteam.product.model.dao.IProductModelPropertyDAO.LastModifierName,
                "lastModifierName");

            queryBean.addSelectProperty(com.ourteam.product.model.dao.IProductModelPropertyDAO.LastModifyTime,
                "lastModifyTime");
        }

        StringBuffer joinSQL = new StringBuffer();

        joinSQL.append(" LEFT JOIN ").append(EntityName).append(" ON ( ");

        joinSQL.append(com.ourteam.product.model.dao.IProductModelPropertyDAO.ObjectId)
               .append(" = ").append(Id);

        joinSQL.append(" ) ");

        String entityName = com.ourteam.product.model.dao.impl.ProductModelPropertyDAO.EntityName +
            " ref_ProductModelProperty";

        return ProductModelPropertyDao.doQuerySelective(entityName, queryBean,
            joinSQL.toString());
    }

    /**
     * Update Related ProductModelProperty
     * @param aProductModelProperty
     * @param aQueryBean
     * @model
     * @throws Exception
     */
    public void updateProductModelProperty(
        com.ourteam.product.model.dao.ProductModelProperty aProductModelProperty,
        ProductModelObjectDAOQueryBean aQueryBean) throws Exception {
        StringBuffer joinSQL = new StringBuffer();

        joinSQL.append(" LEFT JOIN ").append(EntityName).append(" ON ( ");

        joinSQL.append(com.ourteam.product.model.dao.IProductModelPropertyDAO.ObjectId)
               .append(" = ").append(Id);

        joinSQL.append(" ) ");

        String entityName = com.ourteam.product.model.dao.impl.ProductModelPropertyDAO.EntityName +
            " ref_ProductModelProperty";

        String[] entityFields = com.ourteam.product.model.dao.impl.ProductModelPropertyDAO.ENTITY_FIELDS;

        String[] entityProperties = com.ourteam.product.model.dao.impl.ProductModelPropertyDAO.ENTITY_PROPERTIES;

        ProductModelPropertyDao.doUpdateByQuery(entityName, entityFields,
            entityProperties, joinSQL.toString(), aProductModelProperty,
            aQueryBean);
    }

    /**
     * Delete Related ProductModelProperty
     * @param aQueryBean
     * @model
     * @throws Exception
     */
    public void deleteProductModelProperty(
        ProductModelObjectDAOQueryBean aQueryBean) throws Exception {
        StringBuffer joinSQL = new StringBuffer();

        joinSQL.append(" LEFT JOIN ").append(EntityName).append(" ON ( ");

        joinSQL.append(com.ourteam.product.model.dao.IProductModelPropertyDAO.ObjectId)
               .append(" = ").append(Id);

        joinSQL.append(" ) ");

        String entityName = com.ourteam.product.model.dao.impl.ProductModelPropertyDAO.EntityName; // + " ref_ProductModelProperty";

        ProductModelPropertyDao.doDeleteByQuery(entityName, joinSQL.toString(),
            aQueryBean);
    }

    public void setProductModelObjectRelateDao(
        com.ourteam.product.model.dao.IProductModelObjectRelateDAO ProductModelObjectRelateDao) {
        this.ProductModelObjectRelateDao = (com.ourteam.product.model.dao.impl.AbstractProductModelObjectRelateDAOJdbcImpl) ProductModelObjectRelateDao;
    }

    /**
     * Query Related ProductModelObjectRelate
    * @param queryBean
     * @throws Exception
     */
    public com.ourteam.product.model.dao.ProductModelObjectRelate[] queryProductModelObjectRelate(
        ProductModelObjectDAOQueryBean queryBean) throws Exception {
        StringBuffer joinSQL = new StringBuffer();

        joinSQL.append(" LEFT JOIN ").append(EntityName).append(" ON ( ");

        joinSQL.append(com.ourteam.product.model.dao.IProductModelObjectRelateDAO.ObjectId)
               .append(" = ").append(Id);

        joinSQL.append(" ) ");

        String entityName = com.ourteam.product.model.dao.impl.ProductModelObjectRelateDAO.EntityName +
            " ref_ProductModelObjectRelate";

        String[] entityFields = com.ourteam.product.model.dao.impl.ProductModelObjectRelateDAO.ENTITY_FIELDS;

        String[] entityProperties = com.ourteam.product.model.dao.impl.ProductModelObjectRelateDAO.ENTITY_PROPERTIES;

        List list = ProductModelObjectRelateDao.doQuery(entityName,
                entityFields, entityProperties, queryBean, joinSQL.toString(),
                new com.ourteam.product.model.dao.impl.ProductModelObjectRelateDAO.JdbcProductModelObjectRelateRowMapper());

        return (com.ourteam.product.model.dao.ProductModelObjectRelate[]) list.toArray(new com.ourteam.product.model.dao.ProductModelObjectRelate[list.size()]);
    }

    /**
     * Query Related ProductModelObjectRelate Selective
     * @param queryBean
     * @return Map[]
     * @model
     * @throws Exception
     */
    public Map<String, Object>[] queryProductModelObjectRelateSelective(
        ProductModelObjectDAOQueryBean queryBean) throws Exception {
        if (queryBean.getSelectProperties().isEmpty()) {
            queryBean.addSelectProperty(com.ourteam.product.model.dao.IProductModelObjectRelateDAO.Id,
                "id");

            queryBean.addSelectProperty(com.ourteam.product.model.dao.IProductModelObjectRelateDAO.RelateCode,
                "relateCode");

            queryBean.addSelectProperty(com.ourteam.product.model.dao.IProductModelObjectRelateDAO.RelateName,
                "relateName");

            queryBean.addSelectProperty(com.ourteam.product.model.dao.IProductModelObjectRelateDAO.ObjectId,
                "objectId");

            queryBean.addSelectProperty(com.ourteam.product.model.dao.IProductModelObjectRelateDAO.RelatedObjectId,
                "relatedObjectId");

            queryBean.addSelectProperty(com.ourteam.product.model.dao.IProductModelObjectRelateDAO.RelatedType,
                "relatedType");

            queryBean.addSelectProperty(com.ourteam.product.model.dao.IProductModelObjectRelateDAO.RelatedConfig,
                "relatedConfig");

            queryBean.addSelectProperty(com.ourteam.product.model.dao.IProductModelObjectRelateDAO.SortIndex,
                "sortIndex");

            queryBean.addSelectProperty(com.ourteam.product.model.dao.IProductModelObjectRelateDAO.Status,
                "status");

            queryBean.addSelectProperty(com.ourteam.product.model.dao.IProductModelObjectRelateDAO.Remarks,
                "remarks");
        }

        StringBuffer joinSQL = new StringBuffer();

        joinSQL.append(" LEFT JOIN ").append(EntityName).append(" ON ( ");

        joinSQL.append(com.ourteam.product.model.dao.IProductModelObjectRelateDAO.ObjectId)
               .append(" = ").append(Id);

        joinSQL.append(" ) ");

        String entityName = com.ourteam.product.model.dao.impl.ProductModelObjectRelateDAO.EntityName +
            " ref_ProductModelObjectRelate";

        return ProductModelObjectRelateDao.doQuerySelective(entityName,
            queryBean, joinSQL.toString());
    }

    /**
     * Update Related ProductModelObjectRelate
     * @param aProductModelObjectRelate
     * @param aQueryBean
     * @model
     * @throws Exception
     */
    public void updateProductModelObjectRelate(
        com.ourteam.product.model.dao.ProductModelObjectRelate aProductModelObjectRelate,
        ProductModelObjectDAOQueryBean aQueryBean) throws Exception {
        StringBuffer joinSQL = new StringBuffer();

        joinSQL.append(" LEFT JOIN ").append(EntityName).append(" ON ( ");

        joinSQL.append(com.ourteam.product.model.dao.IProductModelObjectRelateDAO.ObjectId)
               .append(" = ").append(Id);

        joinSQL.append(" ) ");

        String entityName = com.ourteam.product.model.dao.impl.ProductModelObjectRelateDAO.EntityName +
            " ref_ProductModelObjectRelate";

        String[] entityFields = com.ourteam.product.model.dao.impl.ProductModelObjectRelateDAO.ENTITY_FIELDS;

        String[] entityProperties = com.ourteam.product.model.dao.impl.ProductModelObjectRelateDAO.ENTITY_PROPERTIES;

        ProductModelObjectRelateDao.doUpdateByQuery(entityName, entityFields,
            entityProperties, joinSQL.toString(), aProductModelObjectRelate,
            aQueryBean);
    }

    /**
     * Delete Related ProductModelObjectRelate
     * @param aQueryBean
     * @model
     * @throws Exception
     */
    public void deleteProductModelObjectRelate(
        ProductModelObjectDAOQueryBean aQueryBean) throws Exception {
        StringBuffer joinSQL = new StringBuffer();

        joinSQL.append(" LEFT JOIN ").append(EntityName).append(" ON ( ");

        joinSQL.append(com.ourteam.product.model.dao.IProductModelObjectRelateDAO.ObjectId)
               .append(" = ").append(Id);

        joinSQL.append(" ) ");

        String entityName = com.ourteam.product.model.dao.impl.ProductModelObjectRelateDAO.EntityName; // + " ref_ProductModelObjectRelate";

        ProductModelObjectRelateDao.doDeleteByQuery(entityName,
            joinSQL.toString(), aQueryBean);
    }

    public static class JdbcProductModelObjectRowMapper implements RowMapper<ProductModelObject> {
        public ProductModelObject mapRow(ResultSet resultSet, int arg1)
            throws SQLException {
            ProductModelObject object = new ProductModelObject();

            int columnIndex = 1;

            int __dataType;

            try {
                Object id = null;

                id = resultSet.getObject(columnIndex++);

                object.setIdNull(resultSet.getBoolean(columnIndex++));

                if (id != null) {
                    setBeanValue(object, _DataObjectProperty.Id, id);
                }

                Object packageId = null;

                packageId = resultSet.getObject(columnIndex++);

                object.setPackageIdNull(resultSet.getBoolean(columnIndex++));

                if (packageId != null) {
                    setBeanValue(object, _DataObjectProperty.PackageId,
                        packageId);
                }

                Object objectCode = null;

                objectCode = resultSet.getObject(columnIndex++);

                object.setObjectCodeNull(resultSet.getBoolean(columnIndex++));

                if (objectCode != null) {
                    setBeanValue(object, _DataObjectProperty.ObjectCode,
                        objectCode);
                }

                Object objectName = null;

                objectName = resultSet.getObject(columnIndex++);

                object.setObjectNameNull(resultSet.getBoolean(columnIndex++));

                if (objectName != null) {
                    setBeanValue(object, _DataObjectProperty.ObjectName,
                        objectName);
                }

                Object objectType = null;

                objectType = resultSet.getObject(columnIndex++);

                object.setObjectTypeNull(resultSet.getBoolean(columnIndex++));

                if (objectType != null) {
                    setBeanValue(object, _DataObjectProperty.ObjectType,
                        objectType);
                }

                Object isGenerate = null;

                isGenerate = resultSet.getObject(columnIndex++);

                object.setIsGenerateNull(resultSet.getBoolean(columnIndex++));

                if (isGenerate != null) {
                    setBeanValue(object, _DataObjectProperty.IsGenerate,
                        isGenerate);
                }

                Object status = null;

                status = resultSet.getObject(columnIndex++);

                object.setStatusNull(resultSet.getBoolean(columnIndex++));

                if (status != null) {
                    setBeanValue(object, _DataObjectProperty.Status, status);
                }

                Object remarks = null;

                remarks = resultSet.getObject(columnIndex++);

                object.setRemarksNull(resultSet.getBoolean(columnIndex++));

                if (remarks != null) {
                    setBeanValue(object, _DataObjectProperty.Remarks, remarks);
                }

                Object submitterId = null;

                submitterId = resultSet.getObject(columnIndex++);

                object.setSubmitterIdNull(resultSet.getBoolean(columnIndex++));

                if (submitterId != null) {
                    setBeanValue(object, _DataObjectProperty.SubmitterId,
                        submitterId);
                }

                Object creatorName = null;

                creatorName = resultSet.getObject(columnIndex++);

                object.setCreatorNameNull(resultSet.getBoolean(columnIndex++));

                if (creatorName != null) {
                    setBeanValue(object, _DataObjectProperty.CreatorName,
                        creatorName);
                }

                Object createTime = null;

                __dataType = resultSet.getMetaData().getColumnType(columnIndex);

                if ((__dataType == java.sql.Types.DATE) ||
                        (__dataType == java.sql.Types.TIME) ||
                        (__dataType == java.sql.Types.TIMESTAMP)) {
                    createTime = resultSet.getTimestamp(columnIndex++);
                } else {
                    createTime = resultSet.getObject(columnIndex++);
                }

                object.setCreateTimeNull(resultSet.getBoolean(columnIndex++));

                if (createTime != null) {
                    setBeanValue(object, _DataObjectProperty.CreateTime,
                        createTime);
                }

                Object lastModifierName = null;

                lastModifierName = resultSet.getObject(columnIndex++);

                object.setLastModifierNameNull(resultSet.getBoolean(
                        columnIndex++));

                if (lastModifierName != null) {
                    setBeanValue(object, _DataObjectProperty.LastModifierName,
                        lastModifierName);
                }

                Object lastModifyTime = null;

                __dataType = resultSet.getMetaData().getColumnType(columnIndex);

                if ((__dataType == java.sql.Types.DATE) ||
                        (__dataType == java.sql.Types.TIME) ||
                        (__dataType == java.sql.Types.TIMESTAMP)) {
                    lastModifyTime = resultSet.getTimestamp(columnIndex++);
                } else {
                    lastModifyTime = resultSet.getObject(columnIndex++);
                }

                object.setLastModifyTimeNull(resultSet.getBoolean(columnIndex++));

                if (lastModifyTime != null) {
                    setBeanValue(object, _DataObjectProperty.LastModifyTime,
                        lastModifyTime);
                }

                Object domainId = null;

                domainId = resultSet.getObject(columnIndex++);

                object.setDomainIdNull(resultSet.getBoolean(columnIndex++));

                if (domainId != null) {
                    setBeanValue(object, _DataObjectProperty.DomainId, domainId);
                }

                Object packageName = null;

                packageName = resultSet.getObject(columnIndex++);

                object.setPackageNameNull(resultSet.getBoolean(columnIndex++));

                if (packageName != null) {
                    setBeanValue(object, _DataObjectProperty.PackageName,
                        packageName);
                }

                Object domainName = null;

                domainName = resultSet.getObject(columnIndex++);

                object.setDomainNameNull(resultSet.getBoolean(columnIndex++));

                if (domainName != null) {
                    setBeanValue(object, _DataObjectProperty.DomainName,
                        domainName);
                }

                Object domainCode = null;

                domainCode = resultSet.getObject(columnIndex++);

                object.setDomainCodeNull(resultSet.getBoolean(columnIndex++));

                if (domainCode != null) {
                    setBeanValue(object, _DataObjectProperty.DomainCode,
                        domainCode);
                }

                return object;
            } catch (Exception e) {
                throw new SQLException(e.getMessage());
            }
        }
    }
}
